<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let array = []
    let sum = 0
    for (let i = 1; i <= 5; i++) {
      let num = +prompt(`请输入第${i}个数字`)
      if (num > 0) {
        array.push(num)
      }
    };
    let array1 = []
    let max = array[0]
    let min = array[0]
    for (let i = 0; i < array.length; i++) {
      sum += array[i]
      if (array[i] >= 18) {
        array1.push(array[i])
      }
      if (max < array[i]) {
        max = array[i]

      }
      if (min > array[i]) {
        min = array[i]

      }

    }
    console.log('所有成年人的年龄', array1);
    console.log('所有人的总年龄', sum);
    console.log(`所有人的平均年龄${sum / array.length}`);
    console.log(`最大年龄是${max}最小年龄是${min}`);





  </script>
</body>

</html>